<!--
 * @Author: your name
 * @Date: 2021-08-18 21:14:32
 * @LastEditTime: 2021-08-29 19:32:56
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \宏烨找房\client-applet\src\views\detail\index.vue
-->
<!--  -->
<template>
  <div class="detail">
    <div class="header">
      <van-icon name="arrow-left" @click="godetail" />
      <span>{{ list.community }}</span>
      <van-icon name="share-o" />
    </div>
    <div class="main">
      <dl>
        <dt>
          <van-swipe :autoplay="3000">
            <van-swipe-item
              v-for="(item, index) in list.houseImg"
              :key="(item, index)"
            >
              <img :src="`http://47.102.145.189:8009${item}`" alt="" />
            </van-swipe-item>
          </van-swipe>
        </dt>
        <dd>
          <div class="HouseDetail">
            <h3 class="title">{{ list.title }}</h3>
            <div class="am-flexbox-item">
              <span
                class="HouseDetail_tag__o8UuR "
                v-for="(item, index) in list.tags"
                :key="(item, index)"
                >{{ item }}
              </span>
            </div>
            <div class="HouseDetail_infoPrice__3SZhW ">
              <div class="jin">
                <div class="infor">
                  {{ list.price }}
                  <span class="HouseDetail_month__uBAXz">/月</span>
                </div>
                <div class="zu">租金</div>
              </div>
              <div class="jin">
                <div class="infor">
                  {{ list.roomType }}
                </div>
                <div class="zu">房型</div>
              </div>
              <div class="jin">
                <div class="infor">{{ list.size }}平米</div>
                <div class="zu">面积</div>
              </div>
            </div>
            <div class="flexbox-align-start">
              <div class="box-item">
                <div><span class="title-iGpj">装修：</span>精装</div>
                <div>
                  <span class="title-iGpj">楼层：</span>{{ list.floor }}
                </div>
              </div>
              <div class="box-item">
                <div
                  v-for="(item, index) in list.oriented"
                  :key="(item, index)"
                >
                  <span class="title-iGpj">朝向：</span>{{ item }}
                </div>
                <div><span class="title-iGpj">类型：</span>普通住宅</div>
              </div>
            </div>
          </div>
        </dd>
      </dl>
    </div>
    <div class="footer">
      <button>
        <van-icon name="star-o" />
        <span>收藏</span>
      </button>
      <button>在线咨询</button>
      <button class="tel">
        <a href="tel:400-618-4000" class="telephone">电话预约</a>
      </button>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      list: [],
    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {
    godetail() {
      this.$router.go(-1);
    },
  },

  //生命周期 - 创建完成（可以访问当前this实例）
  created() {
    this.id = this.$route.params.id;
    console.log(this.id);
    axios.get(`http://47.102.145.189:8009/houses/${this.id}`).then((res) => {
      console.log(res.data.body);
      this.list = res.data.body;
    });
  },
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
};
</script>
<style lang="scss" scoped>
.detail {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: #f6f5f6;
  .header {
    width: 100%;
    height: 40px;
    background: #21b97a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    font-size: 16px;
    color: #fff;
  }
  .main {
    width: 100%;
    flex: 1;
    overflow-y: auto;
    dl {
      dt {
        .van-swipe {
          height: 212px;
          img {
            width: 100%;
            height: 212px;
          }
        }
      }
      dd {
        .HouseDetail {
          padding: 15px;
          background: #fff;
          .title {
            font-weight: 400;
            font-size: 16px;
            color: #333;
          }
          .am-flexbox-item {
            margin-top: 10px;
            .HouseDetail_tag__o8UuR {
              display: inline-block;
              font-size: 12px;
              border-radius: 3px;
              padding: 4px 5px;
              margin-right: 5px;
              line-height: 12px;
              flex: auto;
              color: #39becd;
              background: #e1f5f8;
            }
          }
          .HouseDetail_infoPrice__3SZhW {
            border-top: 1px solid #cecece;
            border-bottom: 1px solid #cecece;
            margin: 15px 0;
            padding: 15px 0;
            align-items: center;
            text-align: left;
            overflow: hidden;
            display: flex;
            .jin {
              box-sizing: border-box;
              flex: 1 1;
              margin-left: 8px;
              min-width: 10px;
              text-align: center;
              color: #999;
            }
            .infor:first-child {
              color: #fa5741;
              font-size: 18px;
              font-weight: bolder;
              height: 26px;
              line-height: 26px;
            }
            .HouseDetail_month__uBAXz {
              font-size: 12px;
              font-weight: 400;
            }
            .zu {
              height: 26px;
              line-height: 26px;
            }
          }
          .flexbox-align-start {
            align-items: flex-start;
            font-size: 13px;
            text-align: left;
            overflow: hidden;
            display: flex;
            align-items: center;
            .box-item {
              box-sizing: border-box;
              flex: 1 1;
              margin-left: 8px;
              min-width: 10px;
              .title-iGpj {
                display: inline-block;
                color: #999;
                padding-right: 5px;
                line-height: 26px;
              }
            }
          }
        }
      }
    }
  }
  .footer {
    width: 100%;
    height: 50px;
    display: flex;
    justify-content: space-between;
    button {
      width: 34%;
      border: none;
      border-top: 1px solid #ccc;
      border-right: 1px solid #ccc;
      font-size: 16px;
      color: #999;
      background: #fff;
    }
    .tel {
      background: #21b97a;
      .telephone {
        color: #fff;
      }
    }
  }
}
</style>
